<template>
  <el-breadcrumb :separator-icon="ArrowRight">
    <el-breadcrumb-item v-for="(n, index) in paths" :key="index" :to="n.path ? { path: n.path } : ''">{{ n.label }}</el-breadcrumb-item>
  </el-breadcrumb>
</template>

<script setup>
import { ArrowRight } from '@element-plus/icons-vue'
import { computed } from 'vue';
import { useRoute } from 'vue-router'

const route = useRoute()
const paths = computed(() => {
  const matchs = route.matched.slice(1).map(item => {
    return {
      label: item.meta.title,
      path: item.redirect ? '' : item.path // 存在重定向设置的，说明path没有实际页面，不予跳转
    }
  })
  return matchs
})
</script>

<style lang="scss" scoped>
.el-breadcrumb {
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background-color: #F3F7FA;
  flex: 0 0 auto;
  :deep(.el-breadcrumb__inner.is-link) {
    font-weight: normal;
  }
}
</style>
